package it.storm.solution;

/**
 * 1603. 设计停车系统
 * https://leetcode-cn.com/problems/design-parking-system/
 */
public class Solutions_1603 {
    public static void main(String[] args) {
        ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
        boolean res1 = parkingSystem.addCar(1);  // output: true
        System.out.println(res1);
        boolean res2 = parkingSystem.addCar(2);  // output: true
        System.out.println(res2);
        boolean res3 = parkingSystem.addCar(3);  // output: false
        System.out.println(res3);
        boolean res4 = parkingSystem.addCar(1);  // output: false
        System.out.println(res4);
    }
}

class ParkingSystem {
    // totals[1] = 3：big 停车场共有车位 3 个
    int[] totals = new int[4];
    // counts[1] = 3：big 停车场已停车 3 辆
    int[] counts = new int[4];

    public ParkingSystem(int big, int medium, int small) {
        totals[1] = big;
        totals[2] = medium;
        totals[3] = small;
    }

    public boolean addCar(int carType) {
        if (counts[carType] >= totals[carType]) {
            // 停不了车了
            return false;
        }
        counts[carType] ++;
        return true;
    }
}
